#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <set>
using namespace std;

class Solution
{
public:
    bool isLongPressedName(string name, string typed)
    {
        int i = 0, j = 0, ch = 0, cnt1 = 0, cnt2 = 0;
        for (; i < name.size() && j < typed.size();)
        {
            ch = name[i];
            cnt1 = 0;
            cnt2 = 0;
            while (name[i] == ch)
                i++, cnt1++;
            while (typed[j] == ch)
                j++, cnt2++;
            if (cnt1 > cnt2)
                return false;
        }
        return i == name.size() && j == typed.size();
    }
};